﻿//JumbotCms_4.1 Final
using System;
using System.Collections.Generic;
using System.Text;
using JumbotCms.Common;
namespace JumbotCms.API
{
    public class FrontAjax : BasicPage
    {
        override protected void OnInit(EventArgs e)
        {
            base.OnInit(e);
            ReturnErrorIP();
            if (!site.IsOpen)
            {
                Response.Write(site.CloseMessage);
                Response.End();
            }
            if (site.IsTiming && !SysOpration(site.OpenTime))
            {
                Response.Write(JsonResult(0, site.CloseMessage));
                Response.End();
            }
        }

        public bool SysOpration(string sysObj)
        {
            string[] t2 = sysObj.Split('|');
            int t1 = t2.Length;
            int time1 = DateTime.Now.Hour;
            if (t1 % 2 != 0)
            {
                return false;
            }
            for (int i = 0; i < t1; i += 2)
            {
                if (time1 < Convert.ToInt32(t2[i].ToString()) || time1 > Convert.ToInt32(t2[i + 1].ToString())) return false;
            }
            return true;
        }
    }
}
